package demo1;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Demo1_3 implements Callable<String> {
    @Override
    public String call() throws Exception {
        return "线程执行完毕";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask = new FutureTask<>(new Demo1_3());
        new Thread(futureTask).start();

//        awaitDone 阻塞式获取执行结果
        System.out.println(futureTask.get());
    }
}
